package com.fdb.efp.basic.framework.mail.config;

import com.fdb.efp.basic.framework.mail.common.MailServerType;

/**
  * 配置接口实现
  * @author hengyh
  * @since 2019年3月15日 下午3:41:49
  * @version 1.0
  */
public class DefaultMailConfigImpl implements MailConfig {

    private final String serverAddress;
    private final String localAddress;
    private final String username;
    private final String password;
    private final Integer port;
    private final Boolean ssl;
    private final MailServerType serverType;
    
    public DefaultMailConfigImpl(
        String serverAddress, 
        String localAddress, 
        String username, 
        String password,
        Integer port,
        Boolean ssl,
        String serverType) {
        this.serverAddress = serverAddress;
        this.localAddress = localAddress;
        this.username = username;
        this.password = password;
        this.port = port;
        this.ssl = ssl;
        this.serverType = MailServerType.valueOf(serverType);
    }

    @Override
    public String serverAddress() {
        return serverAddress;
    }

    @Override
    public String localAddress() {
        return localAddress;
    }

    @Override
    public String username() {
        return username;
    }

    @Override
    public String password() {
        return password;
    }

    @Override
    public Integer port() {
        return port;
    }

    @Override
    public Boolean ssl() {
        return ssl;
    }

    @Override
    public MailServerType serverType() {
        return serverType;
    }

    @Override
    public MailConfig copy() {
        return new DefaultMailConfigImpl(
            this.serverAddress, 
            this.localAddress, 
            this.username, 
            this.password,
            this.port,
            this.ssl,
            this.serverType.name());
    }
}
